package com.tyust.service;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tyust.dao.SupplierDao;
import com.tyust.entity.PageUtils;
import com.tyust.entity.Supplier;
@Service("supplierService")
public class SupplierServiceImpl implements SupplierService {


	@Autowired
	private SupplierDao supplierDao;
	@Override
	public void add(Supplier supplier) throws SQLException {
		supplierDao.add(supplier);
	}

	public PageUtils searchSupplierInfo(Supplier staff) {
		List<Supplier> list = supplierDao.searchSupplierInfo(staff);
		return toPageBean(list,staff);
	}
	private PageUtils toPageBean(List<Supplier> list,Supplier supplier){
		Integer tr= findSupplierCount(supplier);
		return new PageUtils(list,tr,supplier.getLimit(),supplier.getPage());
	}
	@Override
	public int findSupplierCount(Supplier supplier) {
		return supplierDao.findSupplierCount(supplier);
	}

	@Override
	public Supplier getSupplierByNo(Supplier staff) {
		return supplierDao.getSupplierByNo(staff);
	}

	@Override
	public void updateSupplierInfo(Supplier staff) {
		supplierDao.updateSupplierInfo(staff);
	}

	@Override
	public void deleteByNo(String supplierNo) {
		supplierDao.deleteByNo(supplierNo);
	}
}
